package com.xss.animtest;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.drawable.AnimationDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.leakcanary.LeakCanary;

public class MainActivity extends AppCompatActivity {

    private ImageView imageView;
    private static final String TAG = "MainActivity";
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LeakCanary.install(this.getApplication());
        setContentView(R.layout.activity_main);
        imageView=findViewById(R.id.image);
        textView=findViewById(R.id.text);
        Log.d(TAG, "onCreate: 0.25f*4="+(0.25f*4));
        Log.d(TAG, "onCreate: 0.25f*4/10="+(0.25f*4/10));
        Log.d(TAG, "onCreate: 0.25f*4%10="+(0.25f*4%10));
        float f=0f;
        String s=""+f;
        Log.d(TAG, "onCreate: s="+s);
        Log.d(TAG, "onCreate: "+s.substring(s.indexOf('.')+1).length());
    }

    public void startAnim(View view) {
        //补间动画
//        Animation animation=AnimationUtils.loadAnimation(this,R.anim.animation_test);
//        imageView.startAnimation(animation);

        //帧动画
//        imageView.setBackgroundResource(R.drawable.frame_animation);
//        AnimationDrawable animationDrawable= (AnimationDrawable) imageView.getBackground();
//        animationDrawable.start();
//        if (!animationDrawable.isRunning()){
//            imageView.setBackgroundResource(R.drawable.ic_launcher_background);
//        }else {
//            Toast.makeText(this,"is running",Toast.LENGTH_SHORT).show();
//        }




        ValueAnimator objectAnimator=ObjectAnimator.ofFloat(textView,
                "translationY",
                0f,1f);
        objectAnimator.start();


    }
}
